<?php
/**
 * Created by PhpStorm.
 * User: DELL
 * Date: 2021/3/5
 * Time: 16:49
 */

namespace App\Api\V1\Models;
use Illuminate\Database\Eloquent\Model;

class Brand extends Model
{
    protected $table = 'brand';
    public $timestamps = false;

    //添加商品品牌
    public function addBrandItem(){
        $data = [
            'goods_category_id'=>'1',
            'name'=>'嘻嘻哈哈',
            'phonetic'=>'xixihaha',
            'description'=>'',
            'logo'=>'',
            'url'=>'',
            'target'=>'_blank',
            'sort'=>'50',
            'status'=>'1',
        ];
        $this->goods_category_id = $data['goods_category_id'];
        $this->name = $data['name'];
        $this->phonetic = $data['phonetic'];
        $this->description = $data['description'];
        $this->logo = $data['logo'];
        $this->url = $data['url'];
        $this->target = $data['target'];
        $this->sort = $data['sort'];
        $this->status = $data['status'];
        if($this->save()){
            return $this->toArray();
        }
        return false;
    }
    //修改商品品牌
    public function setBrandItem(){
        $data = [
            'goods_category_id'=>'1',
            'name'=>'嘻嘻哈哈',
            'phonetic'=>'xixihaha',
            'description'=>'',
            'logo'=>'',
            'url'=>'',
            'target'=>'_blank',
            'sort'=>'50',
            'status'=>'1',
        ];
       $res = Brand::where('brand_id',3)->update($data);
       if($res){
           return $this->toArray();
       }
       return false;
    }
    //删除一个商品品牌
    public function delBrandItem(){
        $res = Brand::where('brand_id',3)->delete();
        if($res){
            return $this->toArray();
        }
        return false;
    }
    //获取品牌列表
    public function getBrandList(){
        return $this->get()->toArray();
    }
}